*IAT SCORING ALGORITHM FROM GREENWALD, NOSEK, & BANAJI, 2003
LAST UPDATE: 03/03/04

This macro will transform a datafile with raw trial latencies (stored as one line per response) 
for a standard format IAT (7 blocks) into a one line summary per subject of the IAT effect using
GNB's new scoring algorithm.

To use this algorithm for your SAS program, perform these two steps:  
(1) Run this script.  The macro should then be loaded into SAS's active memory.  
(2) In your SAS program, enter the following statement 

%iatCalc(libIn, libOut, indata, outdata, BLOCNAME, SESHID, TRLLATNC, TRLERROR, VERROR, VEXTREME, VSD)

and replace the dummy values with the ones that correspond to your own datafiles and variable names.  


Descriptions of what the macro expects for input, and what it will output are below.  Also, at the 
bottom of this commenting section, there is a sample SAS script that would invoke this macro (assuming 
that you have already run the macro to get it into SAS's active memory).

   The macro expects the following types of libraries, datafiles, and data:
      libIn     = input SAS library name
      libOut    = output SAS library name
      indata    = filename of input SAS dataset in the input SAS library
      outdata   = filename for the output SAS dataset in the output SAS library
      BLOCNAME  = variable name for block identifier in the indata file: alphanumeric indication of the 
                  four trial blocks ('B3', 'B4', 'B6', 'B7' are critical blocks corresponding 
                  to B3, B4, B6, and B7 from GNB, 2002).  At present the macro requires that the variable 
                  passed here uses the names 'B3', 'B4', 'B6', 'B7' to refer to the B3-B7 blocks
	  SESHID    = variable name for unique subject identifier in the indata file
	  TRLLATNC  = variable name for latency of response for trial in the indata file
	  TRLERROR  = variable name for error coding: 0 if initial response was correct, 1 if initial response 
                  was incorrect in the indata file
      VERROR    = value: if '1' the algorithm will use error trial latencies, if '2' the algorithm will replace 
                  error trial latencies with blockmean+600
      VEXTREME  = value: if '1' the algorithm provides no treatment of extreme values, if '2' the algorithm
                  will delete trials <400ms
      VSTD      = value: if '1' the block standard deviation is performed including corrected error trials,
                  if '2' the block standard deviation is performed on correct responses only (1 is standard)

   The macro will output the following variables to the outdata file:
      SESHID  = unique subject identifier
      SUBEXCL = 0 for inclusion data, 1 for excluded data, 2 for incomplete data
      MB3     = mean of trial latencies for B3
      MB4     = mean of trial latencies for B4
      MB6     = mean of trial latencies for B6
      MB7     = mean of trial latencies for B7
      CS1     = standard deviation for B3 and B6 trials combined (correct trials only)
      CS2     = standard deviation for B4 and B7 trials combined (correct trials only)
      AS1     = standard deviation for B3 and B6 trials combined (all trials)
      AS2     = standard deviation for B4 and B7 trials combined (all trials)
      EB3     = percent errors of trials for B3
      EB4     = percent errors of trials for B4
      EB6     = percent errors of trials for B6
      EB7     = percent errors of trials for B7
      FB3     = percent fast responses of trials for B3
      FB4     = percent fast responses of trials for B4
      FB6     = percent fast responses of trials for B6
      FB7     = percent fast responses of trials for B7
      DIFF1   = MB6 - MB3
      DIFF2   = MB7 - MB4
      IAT1    = DIFF1/STD1
      IAT2    = DIFF2/STD2
	  IAT     = mean of IAT1 and IAT2
;

/* SAMPLE SAS SCRIPT THAT USES THIS MACRO ASSUMING THAT IT IS IN ACTIVE SAS MEMORY
This sample script opens two libraries called 'web' and 'outdata'. In the 'web' library a SAS file 
named 'iatrace350000' already exists and will be pulled into active memory by the macro.  When the macro 
finishes it will output the result data into a file in the library 'outdata' called 'Ciatrace350000'. The 
information coding the name of the block is in the variable BLOCK (which is passed to 'BLOCNAME' for
the algorithm). The information coding subject ID is SUB (passed to 'SESHID').  The information coding
the latency of each trial is in LATENCY (passed to TRLLATNC).  The information coding whether an error
was made on each trial is in ERROR (passed to TRLERROR).  And, the setting '2' for VERROR means that 
error latencies will be replaced with the blockmean+600.  The setting '2' for VEXTREME means that responses
faster than 400ms will be deleted before calculating the IAT effect. The setting '1' for VSTD means that 
the standard deviations will be calculated after recombining error trials so the range of D values is bounded 
between (-2,2).  When the algorithm finishes and saves the output, the proc means statement will calculate a 
mean of the IAT effects across subjects (after excluding 'bad' subjects).

libname web 'H:\raceatt\';
libname outdata 'H:\raceattclean\';
%iatCalc(web, outdata, iatrace350000, Ciatrace350000, BLOCK, SUB, LATENCY, ERROR, 2, 2,1);
proc means (data=outdata.Ciatrace350000);var IAT;where SUBEXCL=0;run;
*/

/*MACROS for NEW IMPLICIT ASSOCIATION TEST SCORING ALGORITHM (Greenwald, Nosek, & Banaji, 2002)*/
%macro iatCalc(libIn, libOut, indata, outdata, BLOCNAME, SESHID, TRLLATNC, TRLERROR, VERROR, VEXTREME, VSTD);
%let divide= /; %let multiply= *; %let add = +; %let subtract = -;
%iatAlgorithm(libIn=&libIn, libOut=&libOut, indata=&indata, outdata=&outdata, BLOCNAME=&BLOCNAME, 
              SESHID=&SESHID, TRLLATNC=&TRLLATNC, TRLERROR=&TRLERROR, VERROR=&VERROR, VEXTREME=&VEXTREME, VSTD=&VSTD);run;
%mend iatCalc;

%macro iatAlgorithm(libIn, libOut, indata, outdata, BLOCNAME, SESHID, TRLLATNC, TRLERROR, VERROR, VEXTREME, VSTD);
data IAT; set &libIn..&indata; 
%*PRELIMINARY STEPS FOR HANDLING WEBDATA FORMATS;
    keep &BLOCNAME &SESHID &TRLLATNC &TRLERROR;
proc sort data=iat; by &SESHID &BLOCNAME;	
	%*options nonotes; %*suppress all Notes to log;	

data IAT; set IAT;

%*STEP 1: Include data from B3, B4, B6, B7;
   if &BLOCNAME in ('B3', 'B4', 'B6', 'B7') then ;
   else delete;

%*STEP 2a: Eliminate trial latencies > 10,000ms;
   if &TRLLATNC > 10000 then delete;

%*STEP 2b: Eliminate subjects for whom more than 10% of trials have latencies < 300ms;
   else if &TRLLATNC < 0 then delete; %*for miscoded data in datafile indicating negative response times;
   else if -1 < &TRLLATNC < 300 then FAST = 1;
   else FAST = 0;

data FASTDATA; set IAT; keep &SESHID &BLOCNAME FAST;
proc sort; by &SESHID &BLOCNAME;
proc means data=IAT noprint; by &SESHID &BLOCNAME; var FAST; output out=means mean=MEAN;
proc transpose data=means prefix=F name=name out=FASTMEAN; by &SESHID; id &BLOCNAME;
data FASTMEAN; set FASTMEAN; where name='MEAN'; FASTM = mean(FB3, FB4, FB6, FB7);
   if FASTM > .10 then SUBEXCL = 1; else SUBEXCL = 0; 
   %*SUBEXCL = 0 (include data), 1 (exclude data - too many fast responses), 2 (exclude data - missing data);
   %*The SUBEXCL variable needed to be reintroduced to the final dataset in STEP 12;

%*STEP 3: Use all trials;
   %*in the conventional algorithm the first two trials of each block would be dropped here;

%*STEP 4: No extreme value treatment <or> delete trial with latencies <400ms;
data IAT; set IAT; 
    %*if &VEXTREME = 1 then do nothing here;
    if &VEXTREME = 2 then do; if &TRLLATNC < 400 then delete; end;

proc sort data=IAT; by &SESHID &BLOCNAME;

%*STEP 5: Compute mean of correct latencies for each block;
data CORR; set IAT;
   %*if &VERROR is 1 then means and SDs will be calculated for the entire set of latencies;
   if &VERROR = 2 then do; if &TRLERROR NE 0 then delete; end;
   keep &SESHID &BLOCNAME &TRLLATNC &TRLERROR;
proc means data=CORR noprint; by &SESHID &BLOCNAME; var &TRLLATNC; output out=means mean=MEAN;
proc transpose data=means prefix=M name=name out=CORRMEAN; by &SESHID; id &BLOCNAME;
data CORRMEAN; set CORRMEAN; where name='MEAN';

%*STEP 6a: Compute pooled SD for B3 & B6, and separately for B4 & B7 for correct trials only;
data SD; set CORR;
   if &TRLERROR NE 0 then delete;  *drop error trials;
   if &BLOCNAME in ('B3', 'B6') then TD = '1';
   else if &BLOCNAME in ('B4', 'B7') then TD = '2';
   else delete;
   drop &BLOCNAME;
proc sort data=SD; by &SESHID TD;
proc means data=SD noprint; by &SESHID TD; var &TRLLATNC; output out=means std=STD;
proc transpose data=means prefix=CS name=name out=CORRSTD2; by &SESHID; id TD;
data CORRSTD2; set CORRSTD2; where name='STD';

%*STEP 6b: Compute pooled SD for B3 & B6, and separately for B4 & B7 including error trials;
data SD; merge IAT CORRMEAN; by &SESHID;
   if &TRLERROR < 0 then delete;
   else if &TRLERROR > 1 then delete; %*get rid of coding errors;
   else if &TRLERROR = 1 and &VERROR = 2 then do;
      if &BLOCNAME in ('B3') then &TRLLATNC = MB3 + 600;
	  else if &BLOCNAME in ('B4') then &TRLLATNC = MB4 + 600;
	  else if &BLOCNAME in ('B6') then &TRLLATNC = MB6 + 600;
	  else if &BLOCNAME in ('B7') then &TRLLATNC = MB7 + 600;
   end;
   if &BLOCNAME in ('B3', 'B6') then TD = '1';
   else if &BLOCNAME in ('B4', 'B7') then TD = '2';
   else delete;
   drop &BLOCNAME;
proc sort data=SD; by &SESHID TD;
proc means data=SD noprint; by &SESHID TD; var &TRLLATNC; output out=means std=STD;
proc transpose data=means prefix=AS name=name out=CORRSTD1; by &SESHID; id TD;
data CORRSTD1; set CORRSTD1; where name='STD';

%*STEP 7: Replace error latencies with block mean + 600ms 
<or> use latency from stimulus onset to correct response (when correct response is required);
data ERR; set IAT;
   keep &SESHID &BLOCNAME &TRLERROR;
   if &TRLERROR < 0 then delete;
   else if &TRLERROR > 1 then delete; %*get rid of coding errors;
proc means data=ERR noprint; by &SESHID &BLOCNAME; var &TRLERROR; output out=means mean=MEAN;
proc transpose data=means prefix=E name=name out=ERRMEAN; by &SESHID; id &BLOCNAME;
data ERRMEAN; set ERRMEAN; where name='MEAN';

%*STEP 7 continued: combining data;
data COMBINE; merge CORRMEAN CORRSTD1 CORRSTD2 ERRMEAN FASTMEAN; by &SESHID; %*combining datasets for calculating final means;
   if &VERROR=2 then do;
      array BLOCKMeans(*) MB: ;
      array BLOCKCstds(*) CS: ;
	  array BLOCKAstds(*) AS: ;
      array BLOCKErrs(*) EB: ;
      do i=1 to dim(BLOCKMeans); %*for each of the four blocks replace error trials with mean + 600ms;
	     BLOCKMeans{i} = (1-BLOCKErrs{i})*BLOCKMeans{i} + (BLOCKErrs{i})*(BLOCKMeans{i}+600);			
      end;
   end;

%*STEP 8: No transformation of latencies;
    %*in the conventional algorithm, raw latencies would be log transformed prior to the transposing in the current format;

%*STEP 9: Average latencies for each of the four blocks;
    %*this step was already accomplished in the do loop above;

%*STEP 10: Compute two differences B6-B3 and B7-B4 (does not account for pairing order);
   DIFF1 = MB6 - MB3;
   DIFF2 = MB7 - MB4;

%*STEP 11: Divide each difference by associated pooled SD from STEP 6a or 6b;
   If &VSTD = 2 then do;
      IAT1 = DIFF1/CS1;
      IAT2 = DIFF2/CS2;
   end;
   else do; %*IF VSTD = 1 also set as default;
      IAT1 = DIFF1/AS1;
	  IAT2 = DIFF2/AS2;
   end; 

%*STEP 12: Average quotients from STEP 11;
   IAT = mean(IAT1, IAT2);

%*if there is missing data, do mark data as excluded (SUBEXCL=2);
   do i=1 to dim(BLOCKMeans);
      if BLOCKMeans{i} = . then SUBEXCL = 2;
   end;
data &libout..&outdata (drop=i name);
	set COMBINE;
run;
%mend iatAlgorithm;
*END OF ALGORITHM;




libname web_in 'C:\SAS data\Brock_In\brock';
libname web_out 'C:\SAS data\Brock_Out';
libname age 'C:\SAS data\Brock_Out\age';
libname race 'C:\SAS data\Brock_Out\race';
libname gender 'C:\SAS data\Brock_Out\gender';
libname seasons 'C:\SAS data\Brock_Out\seasons';


*READING IN DATA;
DATA web_in.explicit;
SET web_in.explicitbrock550000 web_in.explicitbrock500000;
RUN;

DATA web_in.implicit;
SET web_in.iatbrock550000 web_in.iatbrock500000;
RUN;

DATA web_in.session;
SET web_in.sessionbrock550000 web_in.sessionbrock500000;
RUN;

DATA web_in.sessiontask;
SET web_in.sessiontaskbrock550000 web_in.sessiontaskbrock500000;
RUN;


/************************************************/
/*                                              */
/*        		Setting IAT Data Up 		    */
/*                                              */
/************************************************/

DATA temp; SET web_in.implicit; 
IF BLOCK_NAME_S in ('BLOCK0', 'BLOCK1', 'BLOCK4') THEN DELETE;
IF TRIAL_ERROR = '0' then TRIALERROR = 0;
ELSE IF TRIAL_ERROR = '1' THEN TRIALERROR = 1;
KEEP TRIAL_NUMBER BLOCK_NAME_S SESSION_ID STUDY_NAME_S BLOCK_PAIRING_DEFINITION_S TRIAL_LATENCY TRIALERROR TASK_NAME_S;
RUN;

PROC SORT DATA=temp;
BY SESSION_ID TASK_NAME_S BLOCK_NAME_S TRIAL_NUMBER;
RUN;

*if prior row is same as current row, mark as a repeat;
DATA temp; SET temp;
repeat = 0;
IF session_id = lag(session_id) and TASK_NAME_S= lag(TASK_NAME_S) AND BLOCK_NAME_S = lag(BLOCK_NAME_S) AND TRIAL_NUMBER = lag(TRIAL_NUMBER) 
THEN repeat=1; 
BY SESSION_ID; 
RUN;

PROC FREQ; 
TABLES repeat; 
RUN;
 
*drop duplicate lines of data;
DATA temp; 
SET temp;
IF repeat = 1 THEN DELETE; 
DROP repeat; 
RUN; 




/************************************************/
/*                                              */
/*        SORTING THROUGH THE FOUR IATS         */
/*                                              */
/************************************************/
DATA reordered; SET temp;
IF task_name_s in ("demo_raceb", "ageb", "demo_genderb", "summerwinter_gbb") THEN DO;
IF BLOCK_NAME_S in ('BLOCK2') THEN BLOCK = 'B6';
ELSE IF BLOCK_NAME_S in ('BLOCK3') THEN BLOCK = 'B7';
ELSE IF BLOCK_NAME_S in ('BLOCK5') THEN BLOCK = 'B3';
ELSE IF BLOCK_NAME_S in ('BLOCK6') THEN BLOCK = 'B4';
END;

ELSE IF if task_name_s in ("demo_racea", "agea", "demo_gendera", "summerwinter_gba") then do;
IF BLOCK_NAME_S in ('BLOCK2') then BLOCK = 'B3';
ELSE IF BLOCK_NAME_S in ('BLOCK3') then BLOCK = 'B4';
ELSE IF BLOCK_NAME_S in ('BLOCK5') then BLOCK = 'B6';
ELSE IF BLOCK_NAME_S in ('BLOCK6') then BLOCK = 'B7';
END;

RUN;



/*************************************************/
/* RACE IAT (Higher scores indicate a pro-white) */
/*************************************************/
DATA web_in.race_iat; SET reordered;
WHERE task_name_s IN ("demo_racea", "demo_raceb");
DROP BLOCK_NAME_S;
RUN;

%iatCalc(web_in, race, race_iat, race_iat_clean, BLOCK, SESSION_ID, TRIAL_LATENCY, TRIALERROR, 1, 2, 1); 

*pull up the raw dataset for use and keep only the necessary variables;
DATA race.input; SET web_in.race_iat;      
KEEP TRIAL_NUMBER BLOCK BLOCK_PAIRING_DEFINITION_S SESSION_ID STUDY_NAME_S TASK_NAME_S TRIALERROR TRIAL_LATENCY;

*sort by session and block so transpose function will work below;
PROC SORT; 
BY SESSION_ID BLOCK; 

/*identifying block pairing definitions*/
DATA race.pairing; 
SET race.input; 
WHERE TRIAL_NUMBER = 1; 
KEEP SESSION_ID BLOCK BLOCK_PAIRING_DEFINITION_S;

PROC TRANSPOSE DATA=race.pairing PREFIX=P NAME=name OUT=race.pairing; 
BY SESSION_ID; 
VAR BLOCK_PAIRING_DEFINITION_S;
ID BLOCK;

*outputs a file with session_id and the block_pairing_defs for all blocks;
PROC SORT DATA=race.PAIRING; 
BY SESSION_ID; 
RUN; 

/*n per block - including extreme outliers; 
vars=nBLOCK0, nBLOCK, ... ; set=ns*/

DATA race.ns; 
SET race.input; 
KEEP SESSION_ID BLOCK TRIAL_NUMBER;

PROC MEANS DATA=race.ns NOPRINT; 
BY SESSION_ID BLOCK; 
VAR TRIAL_NUMBER; 
OUTPUT OUT=race.means n=N;
 
PROC TRANSPOSE DATA=race.means 
PREFIX=N NAME=name OUT=race.spdmeans; 
BY SESSION_ID; 
ID BLOCK;

PROC SORT DATA=race.spdmeans; 
BY SESSION_ID;

*outputs a file with the number of actual trials in each block;
DATA race.ns; 
SET race.spdmeans; 
WHERE name='N';
RUN;


/************************************************/
/* AGE IAT (Higher scores indicate a pro-young) */
/************************************************/
DATA web_in.age_iat; SET reordered;
WHERE task_name_s IN ("agea", "ageb");
DROP BLOCK_NAME_S;
RUN;

%iatCalc(web_in, age, age_iat, age_iat_clean, BLOCK, SESSION_ID, TRIAL_LATENCY, TRIALERROR, 1, 2, 1); 

PROC CONTENTS DATA=age.age_iat_clean;
RUN;

*pull up the raw dataset for use and keep only the necessary variables;
DATA age.input; 
SET web_in.age_iat;   
KEEP TRIAL_NUMBER BLOCK BLOCK_PAIRING_DEFINITION_S SESSION_ID STUDY_NAME_S TASK_NAME_S TRIALERROR TRIAL_LATENCY;

*sort by session and block so transpose function will work below;
PROC SORT; 
BY SESSION_ID BLOCK;  

/*identify block pairing definitions*/
DATA age.pairing; 
SET age.input; 
WHERE TRIAL_NUMBER = 1; 
KEEP SESSION_ID BLOCK BLOCK_PAIRING_DEFINITION_S;

PROC TRANSPOSE DATA=age.pairing PREFIX=P NAME=name OUT=age.pairing; 
BY SESSION_ID; 
VAR BLOCK_PAIRING_DEFINITION_S;
ID BLOCK;

*outputs a file with session_id and the block_pairing_defs for all blocks;
PROC SORT DATA=age.PAIRING; 
BY SESSION_ID; 
RUN; 

/*n per block - including extreme outliers; 
vars=nBLOCK0, nBLOCK, ... ; set=ns*/

DATA age.ns; 
SET age.input; 
KEEP SESSION_ID BLOCK TRIAL_NUMBER;

PROC MEANS DATA=age.ns NOPRINT; 
BY SESSION_ID BLOCK; 
VAR TRIAL_NUMBER; 
OUTPUT OUT=age.means n=N; 

PROC TRANSPOSE DATA=age.means PREFIX=N NAME=name OUT=age.spdmeans; 
BY SESSION_ID; 
ID BLOCK;

PROC SORT DATA=age.spdmeans; 
BY SESSION_ID;

*outputs a file with the number of actual trials in each block;
DATA age.ns; 
SET age.spdmeans; 
WHERE name='N';
RUN; 




/********************************************************/
/*       SEASONS (Higher scores indicate a pro-summer)  */
/********************************************************/
DATA web_in.seasons_iat; SET reordered;
WHERE task_name_s IN ("summerwinter_gba", "summerwinter_gbb");
DROP BLOCK_NAME_S;
RUN;

%iatCalc(web_in, seasons, seasons_iat, seasons_iat_clean, BLOCK, SESSION_ID, TRIAL_LATENCY, TRIALERROR, 1, 2, 1); 

DATA seasons.input; SET web_in.seasons_iat; 
KEEP TRIAL_NUMBER BLOCK BLOCK_PAIRING_DEFINITION_S SESSION_ID STUDY_NAME_S TASK_NAME_S TRIALERROR TRIAL_LATENCY;

PROC SORT; 
BY SESSION_ID BLOCK;  

/*identify block pairing definitions*/
DATA seasons.pairing; SET seasons.input; 
WHERE TRIAL_NUMBER = 1; 
KEEP SESSION_ID BLOCK BLOCK_PAIRING_DEFINITION_S;

PROC TRANSPOSE DATA=seasons.pairing PREFIX=P NAME=name OUT=seasons.pairing; 
BY SESSION_ID; 
VAR BLOCK_PAIRING_DEFINITION_S;
ID BLOCK;

PROC SORT DATA=seasons.PAIRING; 
BY SESSION_ID; 
RUN; 

/*n per block - including extreme outliers; 
vars=nBLOCK0, nBLOCK, ... ; set=ns*/

DATA seasons.ns; SET seasons.input; 
KEEP SESSION_ID BLOCK TRIAL_NUMBER;

PROC MEANS DATA=seasons.ns NOPRINT; 
BY SESSION_ID BLOCK; 
VAR TRIAL_NUMBER; 
OUTPUT OUT=seasons.means n=N; 

PROC TRANSPOSE DATA=seasons.means PREFIX=N NAME=name OUT=seasons.spdmeans; 
BY SESSION_ID; 
ID BLOCK;

PROC SORT DATA=seasons.spdmeans; 
BY SESSION_ID;

DATA seasons.ns; SET seasons.spdmeans; 
WHERE name='N';
RUN; 




/********************************************************/
/*     GENDERSCI (Higher scores indicate a pro-male)    */
/********************************************************/
DATA web_in.gendsci_iat; SET reordered;
WHERE task_name_s IN ("demo_genderb", "demo_gendera");
DROP BLOCK_NAME_S;
RUN;

%iatCalc(web_in, gender, gendsci_iat, gendsci_iat_clean, BLOCK, SESSION_ID, TRIAL_LATENCY, TRIALERROR, 1, 2, 1); 

DATA gender.input; SET web_in.gendsci_iat;   
KEEP TRIAL_NUMBER BLOCK BLOCK_PAIRING_DEFINITION_S SESSION_ID STUDY_NAME_S TASK_NAME_S TRIALERROR TRIAL_LATENCY;

PROC SORT; 
BY SESSION_ID BLOCK;  

/*identify block pairing definitions*/
DATA gender.pairing; SET gender.input; 
WHERE TRIAL_NUMBER = 1; 
KEEP SESSION_ID BLOCK BLOCK_PAIRING_DEFINITION_S;

PROC TRANSPOSE DATA=gender.pairing PREFIX=P NAME=name OUT=gender.pairEng; 
BY SESSION_ID; 
VAR BLOCK_PAIRING_DEFINITION_S;
ID BLOCK;

PROC SORT DATA=gender.PAIRING; 
BY SESSION_ID; 
RUN; 

/*n per block - including extreme outliers; 
vars=nBLOCK0, nBLOCK, ... ; set=ns*/

DATA gender.ns; SET gender.input; 
KEEP SESSION_ID BLOCK TRIAL_NUMBER;

PROC MEANS DATA=gender.ns NOPRINT; 
BY SESSION_ID BLOCK; 
VAR TRIAL_NUMBER; 
OUTPUT OUT=gender.means n=N; 

PROC TRANSPOSE DATA=gender.means PREFIX=N NAME=name OUT=gender.spdmeans; 
BY SESSION_ID; 
ID BLOCK;

PROC SORT DATA=gender.spdmeans; 
BY SESSION_ID;

DATA gender.ns; SET gender.spdmeans; 
WHERE name='N';
RUN;



/************************************************/
/*                                              */
/*        DIFFERENTATING THE CONDITIONS         */
/*                                              */
/************************************************/

DATA temp4; SET web_in.sessiontask; 

PROC SORT; 
BY session_id task_number task_url_s;

DATA temp4; SET temp4;
DROP ip_address user_id task_id_s; 
repeat=0;
task_url_s = tranwrd(task_url_s,"/user/brock/","");
	
IF SESSION_ID = lag(SESSION_ID) and TASK_NUMBER = lag(TASK_NUMBER) and TASK_URL_S = lag(TASK_URL_S) THEN repeat=1;

DATA temp4; SET temp4;
IF repeat = 1 THEN DELETE;  *dropping repeat data;
IF kindex(TASK_URL_S,"iat") THEN DO; 
TASK_URL_S = "IAT"; 
END;

ELSE IF kindex(TASK_URL_S,"debriefing") THEN DO;
TASK_URL_S = "DEBRIEF"; 
END;

ELSE IF kindex(TASK_URL_S,"concepts") THEN DO;
TASK_URL_S = "CONCEPTS"; 
END; 

ELSE IF kindex(TASK_URL_S,"explicit") THEN DO; 
TASK_URL_S = "EXPLICIT"; 
END;

PROC SORT DATA=temp4; 
BY session_id;

PROC TRANSPOSE DATA=temp4 NAME=name OUT=taskID PREFIX=task; 
BY SESSION_ID; 
VAR TASK_URL_S;
ID TASK_NUMBER; 

PROC TRANSPOSE DATA=temp4 NAME=name OUT=timeID PREFIX=time; 
BY SESSION_ID; 
VAR TASK_CREATION_DATE;
ID TASK_NUMBER;

PROC SORT DATA=taskID; 
BY session_id; 
PROC SORT DATA=timeID; 
BY session_id;

DATA temp4; 
MERGE taskID timeID; 
BY session_ID; 
DROP _LABEL_ name;
RUN;

DATA web_out.sessioninfo; SET temp4;
IF task3 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task3 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task3 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task3 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task4 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task4 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task4 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task4 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task5 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task5 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task5 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task5 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task6 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task6 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task6 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task6 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task7 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task7 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task7 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task7 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task8 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task8 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task8 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task8 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task9 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task9 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task9 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task9 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

IF task10 IN (' cartoonmanipbrowna.html', ' cartoonmanipbrownb.html', ' cartoonmanipelerooa.html', ' cartoonmanipeleroob.html', ' cartoonmanipflintstoneb.html', ' cartoonmanipflintstonea.html', ' cartoonmaniphemana.html', ' cartoonmaniphemanb.html', ' cartoonmanipjema.html', ' cartoonmanipjemb.html', ' cartoonmanipjetsona.html', ' cartoonmanipjetsonb.html', ' cartoonmanipscoobya.html', ' cartoonmanipscoobyb.html', ' cartoonmanipyogib.html',' cartoonmanipyogia.html') THEN condition = 4;
ELSE IF task10 IN (' racemanipjemisona.html', ' racemanipjemisonb.html', ' racemanipjordanb.html', ' racemanipjordana.html', ' racemanipkinga.html', ' racemanipkingb.html', ' racemanipmandelaa.html', ' racemanipmadelab.html', ' racemanipmorrisona.html', ' racemanipmorrisonb.html', ' racemanipowensa.html', ' racemanipowensb.html', ' racemanipwashingtona.html', ' racemanipwashingtonb.html', ' racemanipwinfreya.html', ' racemanipwinfreyb.html') THEN condition = 1;
ELSE IF task10 IN (' genscimanipbondarb.html', ' genscimanipbondara.html', ' genscimanipcurieb.html', ' genscimanipcuriea.html', ' genscimanipgermainb.html', ' genscimanipgermaina.html', ' genscimanipgoodalla.html', ' genscimanipgoodallb.html', ' genscimaniphockfieldb.html', ' genscimaniphockfielda.html', ' genscimaniphopperb.html', ' genscimaniphoppera.html', ' genscimanipmcclintocka.html', ' genscimanipmcclintockb.html', ' genscimanipmentena.html', ' genscimanipmentenb.html') THEN condition = 3;
ELSE IF task10 In (' agemanipdouglasb.html', 'agemanipdouglasa.html', ' agemanipbellb.html', ' agemanipbella.html', ' agemanipensteina.html', 'agemanipensteinb.html', ' agemanipghandib.html', ' agemanipghandia.html', ' agemanipjenningsa.html', ' agemanipjenningsb.html', ' agemaniplamaa.html', ' agemaniplamab.html', ' agemanipteresaa.html', ' agemanipteresab.html', ' agemanipredforda.html', ' agemanipredfordb.html') THEN condition = 2;

RUN;

PROC FREQ;
TABLES condition;
RUN;


/*Condition 1 = Race manipulation;
/*Condition 2 = Age manipulation;
/*Condition 3 = Gender Science manipulation;
/*Condition 4 = Control manipulation;





/************************************************/
/*                                              */
/*                EXPLICIT DATA                 */
/*                                              */
/************************************************/


DATA web_out.new_explicit; SET web_in.explicit;
IF question_name_s = "text" OR question_name_s = "d" THEN DELETE; 
RUN;

PROC SORT; 
BY session_id; 
RUN;

PROC TRANSPOSE DATA= web_out.new_explicit OUT=web_out.clean_explicit; 
BY session_id;
ID question_name_s; 
VAR question_response_s; 
RUN;

DATA web_out.clean_explicit_all;
MERGE web_out.clean_explicit web_out.sessioninfo;
BY session_id;
DROP _NAME_;
RUN;


/********************************************************/
/*            RECODING DATA INTO NUMERIC DATA           */
/********************************************************/

DATA web_out.clean_explicit_all; SET web_out.clean_explicit_all;
IF age = '90+' THEN age = '90';
age1 = age * 1;
IF sex = 'f' THEN sex1 = 0;
IF sex = 'm' THEN sex1 = 1;
politicalid1 = politicalid * 1;
major1 = major * 1;
religion1 = religion * 1;
religionid1 = religionid * 1;
ethnic1 = ethnic * 1;
Tblack1 = Tblack * 1;
Twhite1 = Twhite * 1;
Told1 = Told * 1;
Tyoung1 = Tyoung * 1;
Tsummer1 = Tsummer * 1;
Twinter1 = Twinter * 1;
Lscience1 = Lscience * 1;
Larts1 = Larts * 1;
attrace1 = attrace * 1;
attage1 = attage * 1;
attseasons1 = attseasons * 1;
science1 = science * 1;
arts1 = arts * 1;
ethnic1 = ethnic * 1;
agejennings1 = agejenningsa * 1;
agejennings2 = agejenningsb * 1;
agebell1 = agebella * 1;
agebell2 = agebellb * 1;
agedouglas1 = agedouglasa * 1;
agedouglas2 = agedouglasb * 1;
ageteresa1 = ageteresaa * 1;
ageteresa2 = ageteresab * 1;
agegandhi1 = agegandhia * 1;
agegandhi2 = agegandhib * 1;
ageeinstein1 = ageeinsteina * 1;
ageeinstein2 = ageeinsteinb * 1;
agelama1 = agelamaa * 1;
agelama2 = agelamab * 1;
ageredford1 = ageredforda * 1;
ageredford2 = ageredfordb * 1;
racejordan1 = racejordana * 1;
racejordan2 = racejordanb * 1;
raceking1 = racekinga * 1;
raceking2 = racekingb * 1;
raceowens1 = raceowensa * 1;
raceowens2 = raceowensb * 1;
racemandela1 = racemandelaa * 1;
racemandela2 = racemandelab * 1;
racewashington1 = racewashingtona * 1;
racewashington2 = racewashingtonb * 1;
racewinfrey1 = racewinfreya * 1;
racewinfrey2 = racewinfreyb * 1; 
racemorrison1 = racemorrisona * 1;
racemorrison2 = racemorrisonb * 1;
racejemison1 = racejemisona * 1;
racejemison2 = racejemisonb * 1; 
gendscigoodall1 = genscigoodalla * 1;
gendscigoodall2 = genscigoodallb * 1;
gendscibondar1 = genscibondara * 1;
gendscibondar2 = genscibondarb * 1;
gendscigermain1 = genscigermaina * 1;
gendscigermain2 = genscigermainb * 1;
gendscicurie1 = genscicuriea * 1;
gendscicurie2 = genscicurieb * 1;
gendscihockfield1 = genscihockfielda * 1;
gendscihockfield2 = genscihockfieldb * 1;
gendscimcclintock1 = genscimcclintocka * 1;
gendscimcclintock2 = genscimcclintockb * 1;
gendscimenten1 = genscimentena * 1;
gendscimenten2 = genscimentenb * 1;
gendscihopper1 = genscihoppera * 1;
gendscihopper2 = genscihopperb * 1;
cartoonscooby1 = cartoonscoobya * 1;
cartoonscooby2 = cartoonscoobyb * 1;
cartoonyogi1 = cartoonyogia * 1;
cartoonyogi2 = cartoonyogib * 1;
cartoonjetson1 = cartoonjetsona * 1;
cartoonjetson2 = cartoonjetsonb * 1;
cartoonflintstone1 = cartoonflintstonea * 1;
cartoonflintstone2 = cartoonflintstoneb * 1;
cartoonbrown1 = cartoonbrowna * 1;
cartoonbrown2 = cartoonbrownb * 1;
cartoonheman1 = cartoonhemana * 1;
cartoonheman2 = cartoonhemanb * 1;
cartoonjem1 = cartoonjema * 1;
cartoonjem2 = cartoonjemb * 1;
cartooneleroo1 = cartoonelerooa * 1;
cartooneleroo2 = cartooneleroob * 1;

IF condition = 2 THEN DO;
age_correct = 0;
IF agejennings1 = 1 THEN age_correct = age_correct + 1;
IF agejennings2 = 1 THEN age_correct = age_correct + 1;
IF agebell1 = 1 THEN age_correct = age_correct + 1;
IF agebell2 = 1 THEN age_correct = age_correct + 1;
IF agedouglas1 = 1 THEN age_correct = age_correct + 1;
IF agedouglas2 = 1 THEN age_correct = age_correct + 1;
IF ageteresa1 = 1 THEN age_correct = age_correct + 1;
IF ageteresa2 = 1 THEN age_correct = age_correct + 1;
IF agegandhi1 = 1 THEN age_correct = age_correct + 1;
IF agegandhi2 = 1 THEN age_correct = age_correct + 1;
IF ageeinstein1 = 1 THEN age_correct = age_correct + 1;
IF ageeinstein2 = 1 THEN age_correct = age_correct + 1;
IF agelama1 = 1 THEN age_correct = age_correct + 1;
IF agelama2 = 1 THEN age_correct = age_correct + 1;
IF ageredford1 = 1 THEN age_correct = age_correct + 1;
IF ageredford2 = 1 THEN age_correct = age_correct + 1;
end;

IF condition = 1 THEN do;
race_correct = 0;
IF racejordan1 = 1 THEN race_correct = race_correct + 1;
IF racejordan2 = 1 THEN race_correct = race_correct + 1;
IF raceking1 = 1 THEN race_correct = race_correct + 1;
IF raceking2 = 1 THEN race_correct = race_correct + 1;
IF raceowens1 = 1 THEN race_correct = race_correct + 1;
IF raceowens2 = 1 THEN race_correct = race_correct + 1;
IF racemandela1 = 1 THEN race_correct = race_correct + 1;
IF racemandela2 = 1 THEN race_correct = race_correct + 1;
IF racewashington1 = 1 THEN race_correct = race_correct + 1;
IF racewashington2 = 1 THEN race_correct = race_correct + 1;
IF racewinfrey1 = 1 THEN race_correct = race_correct + 1;
IF racewinfrey2 = 1 THEN race_correct = race_correct + 1;
IF racemorrison1 = 1 THEN race_correct = race_correct + 1;
IF racemorrison2 = 1 THEN race_correct = race_correct + 1;
IF racejemison1 = 1 THEN race_correct = race_correct + 1;
IF racejemison2 = 1 THEN race_correct = race_correct + 1;
end;

IF condition = 3 THEN do;
gender_correct = 0;
IF gendscigoodall1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscigoodall2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscibondar1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscibondar2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscigermain1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscigermain2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscicurie1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscicurie2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscihockfield1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscihockfield2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscimcclintock1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscimcclintock2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscimenten1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscimenten2 = 1 THEN gender_correct = gender_correct + 1;
IF gendscihopper1 = 1 THEN gender_correct = gender_correct + 1;
IF gendscihopper2 = 1 THEN gender_correct = gender_correct + 1;
end;

IF condition = 4 THEN do;
control_correct = 0;
IF cartoonscooby1 = 1 THEN control_correct = control_correct + 1;
IF cartoonscooby2 = 1 THEN control_correct = control_correct + 1;
IF cartoonyogi1 = 1 THEN control_correct = control_correct + 1;
IF cartoonyogi2 = 1 THEN control_correct = control_correct + 1;
IF cartoonjetson1 = 1 THEN control_correct = control_correct + 1;
IF cartoonjetson2 = 1 THEN control_correct = control_correct + 1;
IF cartoonflintstone1 = 1 THEN control_correct = control_correct + 1;
IF cartoonflintstone2 = 1 THEN control_correct = control_correct + 1;
IF cartoonbrown1 = 1 THEN control_correct = control_correct + 1;
IF cartoonbrown2 = 1 THEN control_correct = control_correct + 1;
IF cartoonheman1 = 1 THEN control_correct = control_correct + 1;
IF cartoonheman2 = 1 THEN control_correct = control_correct + 1;
IF cartoonjem1 = 1 THEN control_correct = control_correct + 1;
IF cartoonjem2 = 1 THEN control_correct = control_correct + 1;
IF cartooneleroo1 = 1 THEN control_correct = control_correct + 1;
IF cartooneleroo2 = 1 THEN control_correct = control_correct + 1;
end;

IF condition = 1 THEN total_correct = race_correct;
IF condition = 2 THEN total_correct = age_correct;
IF condition = 3 THEN total_correct = gender_correct;
IF condition = 4 THEN total_correct = control_correct;

DROP age;
RUN;

/********************************************************/
/*            MERGING ALL IAT DATA TOGETHER             */
/********************************************************/

DATA race.raceiat;
MERGE 	race.race_iat_clean
		race.pairing(rename=(PB3=RPB3 PB4=RPB4 PB6=RPB6 PB7=RPB7))
		race.ns(rename=(NB3=RNB3 NB4=RNB4 NB6=RNB6 NB7=RNB7));
BY session_id;
raceiat = IAT;
REB3 = EB3;
REB4 = EB4;
REB6 = EB6;
REB7 = EB7;
R_exclude = subexcl;
KEEP raceiat session_id REB3 REB4 REB6 REB7 RNB3 RNB4 RNB6 RNB7 RPB3 RPB4 RPB6 RPB7 R_exclude;

PROC SORT;
BY session_id;
RUN;

DATA gender.gendsciiat;
MERGE 	gender.gendsci_iat_clean
		gender.pairing(rename=(PB3=GPB3 PB4=GPB4 PB6=GPB6 PB7=GPB7))
		gender.ns(rename=(NB3=GNB3 NB4=GNB4 NB6=GNB6 NB7=GNB7));
BY session_id;
gendsciiat = IAT;
gendsciiat= 0 - gendsciiat;
GEB3 = EB3;
GEB4 = EB4;
GEB6 = EB6;
GEB7 = EB7;
G_exclude = subexcl;
KEEP gendsciiat session_id GEB3 GEB4 GEB6 GEB7 GNB3 GNB4 GNB6 GNB7 GPB3 GPB4 GPB6 GPB7 G_exclude;

PROC SORT;
BY session_id;
RUN;

DATA seasons.seasonsiat;
MERGE 	seasons.seasons_iat_clean 
		seasons.pairing(rename=(PB3=SPB3 PB4=SPB4 PB6=SPB6 PB7=SPB7))
		seasons.ns(rename=(NB3=SNB3 NB4=SNB4 NB6=SNB6 NB7=SNB7));
BY session_id;
seasonsiat = IAT;
seasonsiat = 0 - seasonsiat;
SEB3 = EB3;
SEB4 = EB4;
SEB6 = EB6;
SEB7 = EB7;
S_exclude = subexcl;
KEEP seasonsiat session_id SEB3 SEB4 SEB6 SEB7 SNB3 SNB4 SNB6 SNB7 SPB3 SPB4 SPB6 SPB7 S_exclude;

PROC SORT;
BY session_id;
RUN;

DATA age.ageiat;
MERGE 	age.age_iat_clean 
		age.pairing(rename=(PB3=APB3 PB4=APB4 PB6=APB6 PB7=APB7)) 
		age.ns(rename=(NB3=ANB3 NB4=ANB4 NB6=ANB6 NB7=ANB7));
BY session_id;
ageiat = IAT;
AEB3 = EB3;
AEB4 = EB4;
AEB6 = EB6;
AEB7 = EB7;
A_exclude = subexcl;
KEEP ageiat session_id AEB3 AEB4 AEB6 AEB7 ANB3 ANB4 ANB6 ANB7 APB3 APB4 APB6 APB7 A_exclude;

PROC SORT;
BY session_id;
RUN;

DATA all_iats;
MERGE race.raceiat gender.gendsciiat seasons.seasonsiat age.ageiat;
BY session_id;
RUN;



/********************************************************/
/*               Looking at Order effects               */
/********************************************************/
PROC SORT DATA = web_in.sessiontask; 
BY session_id task_url_s; 
DATA web_out.taskorder; SET web_in.sessiontask;
repeat=0;
IF session_id = lag(session_id) and task_url_s = lag(task_url_s)THEN repeat=1; *if prior row is same as current row, mark as a repeat;

PROC FREQ; 
TABLES repeat; 
RUN;

DATA web_out.taskorder; SET web_out.taskorder;
IF repeat = 1 THEN DELETE; 
DROP repeat; 
RUN; *drop duplicate lines of data;

DATA web_out.taskorder; SET web_out.taskorder;
 *tranwrd looks for the first string in quotes and replaces it with the second string in quotes;
 task_url_s = tranwrd(task_url_s,"/common/en-us/html/IATTask.jsp?i=/implicit/user/brock/","");
 task_url_s = tranwrd(task_url_s,".html","");
 task_url_s = tranwrd(task_url_s,"/common/en-us/html/","");
 task_url_s = tranwrd(task_url_s,"/user/brock/","");
 task_url_s = tranwrd(task_url_s,".xml&","");
 task_url_s = tranwrd(task_url_s,".jsp","");
 task_url_s = tranwrd(task_url_s,".xml","");

PROC SORT;
BY session_id;
RUN;

PROC MEANS;
CLASS task_url_s;
VAR task_number;
RUN;

PROC CONTENTS;
RUN;

PROC TRANSPOSE DATA = web_out.taskorder OUT = web_out.clean_task_order; 
BY session_id;
ID task_url_s; 
VAR task_number; 
RUN;

DATA web_out.sessiontask; SET web_in.sessiontask;
IF session_id = lag(session_id) THEN repeat=1;
IF repeat = 1 THEN DELETE; 
DROP repeat;
KEEP 
session_id
session_status
user_id;
RUN;

PROC SORT;
BY session_id;
RUN;

PROC SORT DATA = web_out.clean_task_order;
BY session_id;
RUN;

DATA web_out.clean_task_order;
MERGE web_out.sessiontask web_out.clean_task_order;
BY session_id;
RUN;

PROC CONTENTS;
RUN;

DATA web_out.clean_task_order; SET web_out.clean_task_order;
IF explicit = 11 THEN DO;
   IEorder = 1;
IF seasonsa > 0 THEN seasons = seasonsa-12; 
ELSE IF seasonsb > 0 THEN seasons = seasonsb-12;

IF gendera > 0 THEN gender = gendera-12; 
ELSE IF genderb > 0 THEN gender = genderb-12;

IF racea > 0 THEN race = racea - 12; 
ELSE IF raceb > 0 THEN race = raceb-12;

IF agea > 0 THEN age = agea-12; 
ELSE IF ageb > 0 THEN age = ageb-12;

END;

ELSE IF explicit = 16 THEN DO;
   IEorder = 2;
IF seasonsa > 0 THEN seasons = seasonsa-11; 
ELSE IF seasonsb > 0 THEN seasons = seasonsb-11;

IF gendera > 0 THEN gender = gendera-11; 
ELSE IF genderb > 0 THEN gender = genderb-11;

IF racea > 0 THEN race = racea-11; 
ELSE IF raceb > 0 THEN race = raceb-11;

IF agea > 0 THEN age = agea-11; 
ELSE IF ageb > 0 THEN age = ageb-11;

END;

RUN;

PROC SORT DATA = web_out.clean_task_order;
BY session_id;
RUN;

PROC SORT DATA = web_out.sessioninfo;
BY session_id;
RUN;

PROC CONTENTS DATA = web_out.clean_task_order;
RUN;

DATA web_out.clean_task_order;
MERGE web_out.clean_task_order web_out.sessioninfo;
BY session_id;
RUN;

DATA web_out.clean_task_order; SET web_out.clean_task_order;
IF condition = 1 and race = 1 THEN iatorder = 1;
IF condition = 1 and race = 2 THEN iatorder = 2;
IF condition = 1 and race = 3 THEN iatorder = 3;
IF condition = 1 and race = 4 THEN iatorder = 4;
IF condition = 2 and age = 1 THEN iatorder = 1;
IF condition = 2 and age = 2 THEN iatorder = 2;
IF condition = 2 and age = 3 THEN iatorder = 3;
IF condition = 2 and age = 4 THEN iatorder = 4;
IF condition = 3 and gender = 1 THEN iatorder = 1;
IF condition = 3 and gender = 2 THEN iatorder = 2;
IF condition = 3 and gender = 3 THEN iatorder = 3;
IF condition = 3 and gender = 4 THEN iatorder = 4;
IF condition = 4 and seasons = 1 THEN iatorder = 1;
IF condition = 4 and seasons = 2 THEN iatorder = 2;
IF condition = 4 and seasons = 3 THEN iatorder = 3;
IF condition = 4 and seasons = 4 THEN iatorder = 4;
RUN;

PROC MEANS DATA = web_out.clean_task_order;
CLASS age;
VAR iatorder;
RUN;



/********************************************************/
/*           DOING FINAL SORT OF ALL FILES              */
/********************************************************/
PROC SORT
DATA = all_iats;
BY session_id;
RUN;

PROC SORT DATA=web_out.clean_explicit_all;
BY session_id;
RUN;

PROC SORT
DATA = web_out.clean_task_order;
BY session_id;
RUN;



/********************************************************/
/*           MERGING ALL DATA TOGETHER                  */
/********************************************************/
DATA web_out.final;
MERGE all_iats web_out.clean_explicit_all web_out.sessioninfo web_out.clean_task_order;
BY session_id;
RUN;


/********************************************************/
/*    GETTING RID OF OUR DATA THAT TESTED STUDY         */
/********************************************************/

DATA web_out.final; SET web_out.final;
IF user_id = 0 THEN _ourIP = 1;
	ELSE IF index(ip_address, '128.143.185.')>0 then _ourIP=1;		
	ELSE IF index(ip_address, '128.143.175.')>0 then _ourIP=1;
	ELSE IF index(ip_address, '128.143.174.')>0 then _ourIP=1; 	
	ELSE IF index(ip_address, '128.143.14.')>0 then _ourIP=1;
	ELSE IF index(ip_address, '140.247.95.')>0 then _ourIP=1;   ELSE IF index(ip_address, '128.208.80.')>0 then _ourIP=1;
	ELSE IF ip_address NE '' then _ourIP = 0; 
ELSE;
RUN; 

/********************************************************/
/*    CHECKING TO MAKE SURE MISSING DATA IS EXPECTED    */
/********************************************************/
PROC MEANS data=web_out.final missing;
CLASS _ourip;
VAR session_id;
RUN;
PROC MEANS data=web_out.final missing;
CLASS study_name;
VAR session_id;
RUN;
PROC MEANS data=web_out.final missing;
CLASS Condition;
VAR session_id;
RUN;

DATA web_out.final1; SET web_out.final;
IF study_name NE "UVA.BrockUniversityStudy" THEN DELETE; 	* ?;
ELSE IF _ourIP NE 0 & _ourIP NE . THEN DELETE;				* 1 observations were from Project Implicit, testing data;
ELSE IF Condition = . THEN DELETE; 			* 151 observations with OrdConsent missing. Database error; 
RUN;

PROC FREQ DATA=web_out.final;
TABLES 
APB3 APB4 APB6 APB7
GPB3 GPB4 GPB6 GPB7
SPB3 SPB4 SPB6 SPB7
RPB3 RPB4 RPB6 RPB7 / MISSING;
RUN;

/********************************************************/
/*             DROPPING SS WHO DIDN'T GET A 0           */
/********************************************************/
DATA web_out.newfinal; SET web_out.final;
IF S_exclude ne 0 THEN seasonsiat = .;
IF R_exclude ne 0 THEN raceiat = .;
IF G_exclude ne 0 THEN gendsciiat = .;
IF S_exclude ne 0 THEN seasonsiat = .;
RUN;

/********************************************************/
/*         EXAMINING PEOPLE WHO GOT TO VERY END         */
/********************************************************/
DATA web_out.lefin; SET web_out.newfinal;
IF session_status ne 'C' THEN DELETE;
RUN;

PROC FREQ DATA = web_out.lefin;
TABLES condition;
RUN;

/********************************************************/
/*     EXAMINING WHO GOT >=6 MANIPULATIONS CORRECT      */
/********************************************************/
DATA web_out.mancheck; SET web_out.lefin;
WHERE total_correct >= 6;
attscience = Lscience1 - Larts1;
RUN;

DATA web_out.lefin; SET web_out.lefin;
attscience = Lscience1 - Larts1;
RUN;

*Checking the total number of answers correct;
*>=7 Cond 1 = 7.8 Cond 2 = 7.8 Cond 3 = 7.3 Cond 4 = 7.3;
*>=6 Cond 1 = 7.8 Cond 2 = 7.7 Cond 3 = 6.8 Cond 4 = 7.0;
*>=5 Cond 1 = 7.8 Cond 2 = 7.7 Cond 3 = 6.6 Cond 4 = 6.9;
*>=4 Cond 1 = 7.8 Cond 2 = 7.7 Cond 3 = 6.5 Cond 4 = 6.9;
*>=3 Cond 1 = 7.8 Cond 2 = 7.7 Cond 3 = 6.5 Cond 4 = 6.9;

PROC MEANS DATA = web_out.mancheck;
CLASS condition;
VAR raceiat;
WHERE IEorder = 1 and race = 1;
RUN;

DATA web_out.mancheck; SET web_out.mancheck;
attage1 = attage1 - 4;
attseasons1 = attseasons1;
attseasonsnew = attseasons1 - 4;
newLscience1 = Lscience1 - 4;
newLarts1 = Larts1 - 4;

IF condition = 1 THEN ncond = 1;
IF condition = 4 THEN ncond = 2;

IF condition = 2 THEN cond = 1;
IF condition = 4 THEN cond = 2;

IF condition = 3 THEN nncond = 1;
IF condition = 4 THEN nncond = 2;

run;

PROC TTEST DATA = web_out.mancheck;
CLASS ncond;
VAR raceiat;
WHERE IEorder = 2 and race = 1;
run;

PROC FREQ DATA = web_out.mancheck;
TABLES condition;
RUN;

PROC TTEST DATA = web_out.mancheck H0 = 0;
VAR attrace1;
RUN;

PROC TTEST DATA = web_out.mancheck;
PAIRED Twhite1*Tblack1; 
RUN;

PROC freq DATA = web_out.mancheck;
TABLES sex1;
RUN;
/**************************************************/
/* THERE ARE FOUR FINAL DATA SETS                 */
/* 1) final - raw DATA with nobody dropped        */
/* 2) newfinal - ss with IATs /= 0 dropped        */
/* 3) lefin - ss not getting a C for the study    */
/* 4) mancheck - only ss >=6 manip questions right*/
/**************************************************/
PROC ttest DATA = web_out.mancheck;
CLASS ncond;
VAR raceiat;
where (IEorder = 2 and race = 1) or IEorder = 1;
RUN;

PROC GLM DATA = web_out.mancheck;
CLASS ncond IEorder;
MODEL attrace1 = ncond | IEorder/ ss3;
RUN;

PROC MEANS DATA = web_out.mancheck;
CLASS ncond;
VAR raceiat;
where (IEorder = 2 and race = 1) or IEorder = 1;
RUN;
/********************************************************/
/*                   DEMOGRAPHICS                       */
/********************************************************/

PROC FREQ DATA = web_out.mancheck;
TABLES ethnic1;
RUN;
PROC MEANS DATA = web_out.mancheck;
VAR raceiat ageiat gendsciiat seasonsiat;
RUN;
PROC MEANS DATA = web_out.final(where=(session_status='C'));
VAR session_id;
RUN;
PROC UNIVARIATE PLOT DATA = web_out.final (where=(session_status='C'));
VAR ethnic1;
RUN;

*Getting general information about all VARiables;
PROC UNIVARIATE PLOT DATA = web_out.final;
VAR age1 religion1 politicalid1 major1 attage1 attrace1 attseasons1 
Lscience1 Larts1 Told1 Tblack1 Twhite1 Twinter1 Tsummer1 Tyoung1;
RUN;

*Getting general information about IATs and number correct for manipulations;
PROC UNIVARIATE PLOT DATA = web_out.final;
VAR gendsciiat raceiat seasonsiat ageiat control_correct age_correct race_correct gender_correct;
RUN;


/********************************************************/
/*                   Looking at MEANS                   */
/********************************************************/
*MEANS for participants on the IAT;
PROC MEANS DATA = web_out.final;
CLASS S_exclude;
VAR seasonsiat;
RUN;
PROC MEANS DATA = web_out.final;
CLASS A_exclude;
VAR ageiat;
RUN;
PROC MEANS DATA = web_out.final;
CLASS R_exclude;
VAR raceiat;
RUN;
PROC MEANS DATA = web_out.final;
CLASS G_exclude;
VAR gendsciiat;
RUN;

*Looking at the MEANS for IATs in each condition;
ODS HTML;
PROC MEANS n mean std stderr DATA = web_out.mancheck;
CLASS condition;
VAR raceiat;
where (IEorder = 2 and race = 1) or IEorder = 1;
RUN;
ODS HTML close;

*Looking at the respective MEANS of the explicit ratings;
ODS HTML;
PROC MEANS n mean stderr stddev DATA = web_out.lefin;
VAR attrace1 attage1 attscience attseasons1;
RUN;
ODS HTML close;

PROC MEANS n mean stderr stddev DATA = web_out.mancheck;
CLASS condition;
VAR Tblack1 Twhite1 Tyoung1 Told1 Tsummer1 Twinter1;
RUN;

*Examining the correlation between the IATS;
PROC sort DATA = web_out.lefin;
by condition;
RUN;

*Looking at the correlation between explicit and implicit;
ODS HTML;
PROC corr DATA = web_out.lefin;
VAR raceiat ageiat gendsciiat seasonsiat attrace1 attage1 attscience attseasons1;
RUN;
ODS HTML close;



/************************************************/
/*                                              */
/*    	      Is there significance?            */
/*                                              */
/************************************************/
*Implicit;
*Condition 1 = Race manipulation;
*Condition 2 = Age manipulation;
*Condition 3 = Gender Science manipulation;
*Condition 4 = Control manipulation;
*IEorder = 1 MEANS explicit first;

DATA web_out.lefin; set web_out.lefin;
IF condition = 1 THEN racemanip = 1;
ELSE racemanip = 0;

IF condition = 2 THEN agemanip = 1;
ELSE agemanip = 0;

IF condition = 3 THEN gendermanip = 1;
ELSE gendermanip = 0;

IF condition = 4 THEN seasonsmanip = 1;
ELSE seasonsmanip = 0;

RUN;

ODS HTML;
PROC GLM DATA = web_out.mancheck;
CLASS condition;
MODEL raceiat = condition/ ss3;
CONTRAST 'race vs others' condition -3 1 1 1;
RUN;
ODS HTML close;

PROC GLM DATA = web_out.mancheck;
CLASS condition;
MODEL ageiat = condition/ ss3;
CONTRAST 'age vs others' condition 1 -3 1 1;
RUN;


PROC GLM DATA = web_out.mancheck;
CLASS condition;
MODEL seasonsiat = condition;
CONTRAST 'control vs others' condition 1 1 1 -3;
RUN;

